package com.mercenary.wein.screenControl.test;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * Created by tuxiao on 2017/3/22.
 */
public class test {
    public static void main(String[] args) throws FileNotFoundException, DocumentException {
        InputStream inputStream = new FileInputStream(new File("F:\\work\\workspace\\screenContrl\\src\\main\\tempdump.xml"));
        SAXReader saxReader = new SAXReader();
        Document document = saxReader.read(inputStream);
        Element rootElement = document.getRootElement();
        String bounds = "";
        for(Object element : rootElement.selectNodes("//node")){
            if(!((Element)element).attribute("text").getValue().equals("微控终端"))continue;
            bounds = ((Element)element).attribute("bounds").getValue();
        }
        String[] xys = bounds.replace("][",",").replace("[","").replace("]","").split(",");
        int[] pixel = new int[2];
        pixel[0] = (Integer.parseInt(xys[0])+Integer.parseInt(xys[2]))/2;
        pixel[1] = (Integer.parseInt(xys[1])+Integer.parseInt(xys[3]))/2;
        System.out.printf(bounds);

    }
}
